package com.stu.controller.admin;

import com.stu.pojo.PageBean;
import com.stu.result.Result;
import com.stu.serive.StuInformationManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("admin")
public class StuInformationManageController {

    @Autowired
    private StuInformationManageService stuInformationManageService;


    /**
     * 学生信息批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("/stu_information")
    public Result delete(@RequestParam List<Long> ids){
        log.info("学生信息批量删除：{}",ids);
        stuInformationManageService.deleteBatch(ids);
        return Result.success();
    }

    /**
     * 分页查询所有学生信息，并且可以根据学生班级、姓名、性别、年纪、学院、政治面貌、专业进行检索
     * @param page
     * @param pageSize

     * @return
     */
    @GetMapping("/stu_information")//分页查询操作
    public Result selectAllStuINF(@RequestParam(defaultValue = "1") Integer page,//@RequestParam 用于将指定的请求参数赋值给方法中的形参中
                         @RequestParam(defaultValue = "1") Integer pageSize,
                         String classInfo,String name, Integer gender, String college, Integer age,
                         String politicalOutlook, String major
                         ){
        //  PageBean 是一个专门用于分页查询的方法，传入指定的参数即可
        PageBean pageBean = stuInformationManageService.selectAllStuINF(page, pageSize,
                classInfo, name, gender, college, age,
                politicalOutlook, major);
        return Result.success(pageBean);
    }
}
